package com.hudongwx.shansun.setting;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;

import com.hudongwx.shansun.R;
import com.hudongwx.shansun.utlis.API;
import com.hudongwx.shansun.utlis.MyJSONobject;

import org.json.JSONException;
import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_about_me)
public class AboutMeActivity extends AppCompatActivity {
    @ViewInject(R.id.aboutme_web)
    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
        RequestParams params = new RequestParams(API.aboutme());
        x.http().get(params, new Callback.CommonCallback<MyJSONobject>() {
            @Override
            public void onSuccess(MyJSONobject result) {
                try {
                    webView.loadUrl(result.getString("about"));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {

            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }

    @Event(R.id.aboutme_iv)
    private void ivBtn(View view) {
        finish();
    }
}
